<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"><title>语雀文章同步至Hexo笔记 | CC的部落格</title><meta name="author" content="CC康纳百川"><meta name="copyright" content="CC康纳百川"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="ffffff"><article data-clarity-region="article"></article><meta name="description" content="这篇文章主要讲一下如何用 GitHub Actions 来部署同步语雀上文章到我们的 Hexo 博客"><meta property="og:type" content="article"><meta property="og:title" content="语雀文章同步至Hexo笔记"><meta property="og:url" content="https://blog.ccknbc.cc/posts/yuque-to-hexo/"><meta property="og:site_name" content="CC的部落格"><meta property="og:description" content="这篇文章主要讲一下如何用 GitHub Actions 来部署同步语雀上文章到我们的 Hexo 博客"><meta property="og:locale" content="zh_CN"><meta property="og:image" content="https://pic1.afdiancdn.com/user/8a7f563c2e3811ecab5852540025c377/common/721e476cb2661152b9c43621c94e3ed7_w1366_h768_s86.png"><meta property="article:published_time" content="2022-10-04T08:00:00.000Z"><meta property="article:modified_time" content="2022-10-04T08:00:00.000Z"><meta property="article:author" content="CC康纳百川"><meta property="article:tag" content="博客"><meta property="article:tag" content="工具"><meta name="twitter:card" content="summary"><meta name="twitter:image" content="https://pic1.afdiancdn.com/user/8a7f563c2e3811ecab5852540025c377/common/721e476cb2661152b9c43621c94e3ed7_w1366_h768_s86.png"><link rel="shortcut icon" href="/favicon.ico"><link rel="canonical" href="https://blog.ccknbc.cc/posts/yuque-to-hexo/"><link rel="preconnect" href="https://jsd.cdn.zzko.cn"><link rel="preconnect" href="//static.cloudflareinsights.com"><link rel="preconnect" href="//www.clarity.ms"><link rel="preconnect" href="//busuanzi.ibruce.info"><link rel="preconnect" href="https://97MUPN4DMC-dsn.algolia.net" crossorigin=""><meta name="google-site-verification" content="tUkgeN6Ih2ArWtjw47oNSSl4Af2_MWjiKLrzZptUCdM"><meta name="msvalidate.01" content="71ADBCC80D679CEA8080BAFDCD54E368"><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://jsd.cdn.zzko.cn/npm/@fortawesome/fontawesome-free/css/all.min.css"><link rel="stylesheet" href="https://jsd.cdn.zzko.cn/npm/node-snackbar/dist/snackbar.min.css" media="print" onload='this.media="all"'><link rel="stylesheet" href="https://jsd.cdn.zzko.cn/npm/@fancyapps/ui/dist/fancybox/fancybox.css" media="print" onload='this.media="all"'><script>(()=>{const t={set:(e,t,a)=>{var o;0!==a&&(o=Date.now(),localStorage.setItem(e,JSON.stringify({value:t,expiry:o+864e5*a})))},get:e=>{var t=localStorage.getItem(e);if(t){t=JSON.parse(t);if(!(Date.now()>t.expiry))return t.value;localStorage.removeItem(e)}}},a=(window.btf={saveToLocal:t,getScript:(o,n={})=>new Promise((t,e)=>{const a=document.createElement("script");a.src=o,a.async=!0,a.onerror=e,a.onload=a.onreadystatechange=function(){var e=this.readyState;e&&"loaded"!==e&&"complete"!==e||(a.onload=a.onreadystatechange=null,t())},Object.keys(n).forEach(e=>{a.setAttribute(e,n[e])}),document.head.appendChild(a)}),getCSS:(o,n=!1)=>new Promise((t,e)=>{const a=document.createElement("link");a.rel="stylesheet",a.href=o,n&&(a.id=n),a.onerror=e,a.onload=a.onreadystatechange=function(){var e=this.readyState;e&&"loaded"!==e&&"complete"!==e||(a.onload=a.onreadystatechange=null,t())},document.head.appendChild(a)}),addGlobalFn:(e,t,a=!1,o=window)=>{var n=o.globalFn||{},d=n[e]||{};a&&d[a]||(d[a=a||Object.keys(d).length]=t,n[e]=d,o.globalFn=n)}},()=>{document.documentElement.setAttribute("data-theme","dark"),null!==document.querySelector('meta[name="theme-color"]')&&document.querySelector('meta[name="theme-color"]').setAttribute("content","#0d0d0d")}),o=()=>{document.documentElement.setAttribute("data-theme","light"),null!==document.querySelector('meta[name="theme-color"]')&&document.querySelector('meta[name="theme-color"]').setAttribute("content","ffffff")};btf.activateDarkMode=a,btf.activateLightMode=o;var e=t.get("theme"),n=window.matchMedia("(prefers-color-scheme: dark)").matches,d=window.matchMedia("(prefers-color-scheme: light)").matches,r=window.matchMedia("(prefers-color-scheme: no-preference)").matches,c=!n&&!d&&!r,n=(void 0===e?(d?o():n?a():(r||c)&&((d=(new Date).getHours())<=6||18<=d?a:o)(),window.matchMedia("(prefers-color-scheme: dark)").addListener(e=>{void 0===t.get("theme")&&(e.matches?a:o)()})):("light"===e?o:a)(),t.get("aside-status"));void 0!==n&&("hide"===n?document.documentElement.classList.add("hide-aside"):document.documentElement.classList.remove("hide-aside"));/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)&&document.documentElement.classList.add("apple")})()</script><script defer data-pjax="data-pjax" src="https://static.cloudflareinsights.com/beacon.min.js" data-cf-beacon="{&quot;token&quot;: &quot;35785b58f09f472ebfd7a2854973e6b8&quot;}"></script><script>!function(t,e,n,a,c,r){t[n]=t[n]||function(){(t[n].q=t[n].q||[]).push(arguments)},(c=e.createElement(a)).async=1,c.src="https://www.clarity.ms/tag/an4gdfm6a9",(r=e.getElementsByTagName(a)[0]).parentNode.insertBefore(c,r)}(window,document,"clarity","script")</script><script>const GLOBAL_CONFIG={postHeadAiDescription:{enable:!0,gptName:"CC",mode:"tianli",switchBtn:!0,btnLink:"https://tianli-blog.club/tianligpt/",randomNum:3,basicWordCount:1e3,key:"VCtoijR43E2uiVWkrZiC",Referer:"https://blog.ccknbc.cc/"},root:"/",algolia:void 0,localSearch:void 0,translate:{defaultEncoding:2,translateDelay:0,msgToTraditionalChinese:"繁",msgToSimplifiedChinese:"简"},noticeOutdate:{limitDay:15,position:"top",messagePrev:"本文最后一次更新为",messageNext:"天前，文章中的某些内容可能已过时！"},highlight:{plugin:"highlight.js",highlightCopy:!0,highlightLang:!0,highlightHeightLimit:!1,highlightFullpage:!0,highlightMacStyle:!0},copy:{success:"复制成功",error:"复制错误",noSupport:"浏览器不支持"},relativeDate:{homepage:!1,post:!1},runtime:"天",dateSuffix:{just:"刚刚",min:"分钟前",hour:"小时前",day:"天前",month:"个月前"},copyright:{limitCount:100,languages:{author:"作者: CC康纳百川",link:"链接: ",source:"来源: CC的部落格",info:"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},lightbox:"fancybox",Snackbar:{chs_to_cht:"你已切换为繁体中文",cht_to_chs:"你已切换为简体中文",day_to_night:"你已切换为深色模式",night_to_day:"你已切换为浅色模式",bgLight:"#49b1f5",bgDark:"#1f1f1f",position:"top-center"},infinitegrid:{js:"https://jsd.cdn.zzko.cn/npm/@egjs/infinitegrid/dist/infinitegrid.min.js",buttonText:"加载更多"},isPhotoFigcaption:!1,islazyload:!0,isAnchor:!1,percent:{toc:!0,rightside:!0},autoDarkmode:!0}</script><script id="config-diff">var GLOBAL_CONFIG_SITE={postAI:"这篇文章主要讲一下如何用 GitHub Actions 来部署同步语雀上文章到我们的 Hexo 博客",pageFillDescription:"关于工作流程构件, 比较构件和依赖项缓存, 上传构建和测试构件, 示例, 配置自定义构件保留期, 下载或删除构件, 在工作流程运行期间下载构件, 在工作流中的作业间传递数据, 踩坑记录, 后续更新查看本文语雀版本首发自动同步更新至的部落格建议直接查看结尾新项目但本文中的思路仍可借鉴缓存缩小到了因为已经使用语雀有一段时间了但是因为使用的是的原因一直没有做什么更新但是目前已经了是时候给缓存找一个地方存档以便后续增量更新了其实最开始的时候是直接推送到仓库的后来有想过推送到的想法但因为更新不怎么频繁也就一直耽搁了但是因为不在使用条款范围内有一定的风险所以还是放弃了在国庆前我就有想法传到这样的网盘但是还是不是很方便最好有现成的脚本可以使用于是我想到了构建产物这个东西我只要先预先生成一次产物然后下次就能把之前的产物下载下来使用关于工作流程构件构件允许您在作业完成后保留数据并与同一工作流程中的另一个作业共享该数据构件是指在工作流程运行过程中产生的文件或文件集例如在工作流程运行结束后您可以使用构件保存您的构建和测试输出默认情况下会将构建日志和项目存储天对于源码公开的我公共仓库是完全够用的只要保证天更新一次博客即可此保留期可以自定义有关详细信息请参阅使用限制计费和管理每当有人向拉取请求推送新提交时拉取请求的保留期都会重新开始计算以下是您可以上传的一些常见构件日志文件和核心转储文件测试结果失败和屏幕截图二进制或压缩文件压力测试性能输出和代码覆盖结果存储构件时使用存储空间有关详细信息请参阅的计费构件会在工作流程运行过程中上传您可以在中查看构件的名称和大小当构件使用下载时作为构件一部分单独上传的所有文件都会压缩到一个文件中这意味着计费是根据上传的构件大小而不是文件的大小计算的提供两项可用于上传和下载构建构件的操作有关详细信息请参阅和操作要在作业之间共享数据上传文件为上传的文件指定一个名称并在作业结束前上传数据下载文件只能下载在同一工作流运行期间上传的工件下载文件时您可以通过名称引用该文件作业步骤共享运行器机器的相同环境但在其各自的进程中运行要在作业的步骤之间传递数据您可以使用输入和输出有关输入和输出的详细信息请参阅的元数据语法比较构件和依赖项缓存构件与缓存类似因为它们能够在上存储文件但每项功能都提供不同的用例不能互换使用当想要重复使用在作业或工作流运行之间不频繁更改的文件时例如从程序包管理系统构建依赖项请使用缓存如果要保存作业生成的文件以在工作流运行结束后查看例如生成的二进制文件或生成日志请使用项目有关依赖项缓存的详细信息请参阅缓存依赖项以加快工作流上传构建和测试构件您可以创建持续集成工作流程来构建和测试您的代码有关使用执行的详细信息请参阅关于持续集成构建和测试代码的输出通常会生成可用于调试测试失败的文件和可部署的生产代码您可以配置一个工作流程来构建和测试推送到仓库中的代码并报告成功或失败状态您可以上传构建和测试输出以用于部署调试失败的测试或崩溃以及查看测试套件范围可以使用操作上传工件上传构件时您可以指定单个文件或目录或多个文件或目录您还可以排除某些文件或目录以及使用通配符模式建议为工件命名如果没有命名则会使用作为默认名称有关语法的详细信息请参阅操作示例例如您的仓库或应用程序可能包含必须转换为和的和文件假设生成配置输出目录中已编译的文件如果所有测试均已成功完成则可将目录中的文件部署到应用服务器此示例演示了如何创建项目的工作流该项目在目录中生成代码在目录中运行测试可以假定运行会生成一个名为存储在目录中的代码覆盖率报告工作流上传目录中的生产工件但不包括任何文件它还将报表作为另一个工件上传配置自定义构件保留期您可以为工作流程创建的单个构件自定义保留期使用工作流创建新工件时可以同时使用和操作此示例演示如何为名为的工件设置天的自定义保留期值不能超过存储库组织或企业设置的保留限制下载或删除构件在工作流运行期间可以使用操作下载以前在同一工作流运行中上传的工件工作流程运行完成后您可以在上或使用下载或删除构件有关详细信息请参阅下载工作流工件删除工作流工件和工件在工作流程运行期间下载构件操作可用于在工作流运行期间下载以前上传的工件注意只能下载在同一工作流运行期间上传的工作流中的工件指定构件的名称以下载单个构件如果在未指定名称的情况下上传了工件则默认名称为您还可以不指定名称而下载工作流程运行中的所有构件如果您在处理大量构件此功能非常有用如果下载所有工作流运行的工件则会为每个工件使用其名称创建一个目录有关语法的详细信息请参阅操作在工作流中的作业间传递数据可以使用和操作在工作流中的作业间共享数据此示例工作流程说明如何在相同工作流程中的任务之间传递数据有关详细信息请参阅和操作依赖于以前作业构件的作业必须等待依赖项成功完成此工作流使用密钥来确保和按顺序运行例如需要方法是使用语法作业执行以下步骤执行数学计算并将结果保存到名为的文本文件使用操作上传工件名称为的文件作业使用上一个作业的结果下载在上一作业中上传的工件默认情况下操作会将工件下载到该步骤执行的工作区目录中可以使用输入参数指定不同的下载目录读取文件中的值执行数学计算并再次将结果保存到覆盖其内容上传文件此上传会覆盖之前上传的构件因为它们共用同一名称作业显示上一个作业中上传的结果下载工件将数学方程式的结果打印到日志中在此工作流示例中执行的完整数学运算是工作流程运行运行将会存档它生成的任何构件踩坑记录首先看看我的工作流文件处理部分代码会发现有一些疑问怎么和文档提到的不太一样如果配合看是不是就明显多了语雀具体实现思路如下语雀缓存及其时间戳我放在博客根目录这个文件夹里文章只要放在下任意目录即可子目录也行上传脚本使用官方的就行下载脚本得使用原因上面也提到了官方的脚本只能下载在同一工作流运行期间上传的工作流中的工件而这位作者的脚本默认下载上次运行成功后构建的产物完美符合我们的需求第一次使用只保留上传脚本注释掉下载脚本因为没有已成功构建产物此外在执行之前因为我没有放在根目录所以还需要创建文件夹命令否则会报错后续使用取消注释掉的下载脚本也可以取消这条命令了因为加了判断也可以不取消一定要注意文章放文章目录下缓存放缓存目录下不然识别到这么大的专属格式会解析报错卡在了后续更新由于原作者以放弃此项目推荐使用他的新项目同步而使用示例也可查看我的仓库",title:"语雀文章同步至Hexo笔记",isPost:!0,isHome:!1,isHighlightShrink:!1,isToc:!0,postUpdate:"2022-10-04 16:00:00"}</script><script>"serviceWorker"in navigator&&(navigator.serviceWorker.register("/sw.js",{scope:"/"}).then(r=>{r.onupdatefound=()=>{const e=r.installing;e.onstatechange=()=>{"installed"===e.state&&(navigator.serviceWorker.controller?(void 0!==GLOBAL_CONFIG.Snackbar&&btf.snackbarShow("已刷新缓存，更新为最新内容"),navigator.serviceWorker.controller.postMessage({type:"skipWaiting"})):console.log("第一次注册Service Worker"))}}}),navigator.serviceWorker.addEventListener("message",e=>{e.data&&"refresh"===e.data.type&&(console.log("收到刷新页面请求，开始刷新页面"),window.location.reload())}))</script><link rel="stylesheet" href="https://jsd.cdn.zzko.cn/npm/hexo-butterfly-tag-plugins-plus/lib/assets/font-awesome-animation.min.css" media="defer" onload='this.media="all"'><link rel="stylesheet" href="https://jsd.cdn.zzko.cn/npm/hexo-butterfly-tag-plugins-plus/lib/tag_plugins.css" media="defer" onload='this.media="all"'><meta name="generator" content="Hexo 7.2.0"><link rel="alternate" href="/atom.xml" title="CC的部落格" type="application/atom+xml"><link rel="alternate" href="/rss.xml" title="CC的部落格" type="application/rss+xml"></head><body><script>window.paceOptions={restartOnPushState:!1},btf.addGlobalFn("pjaxSend",()=>{Pace.restart()},"pace_restart")</script><link rel="stylesheet" href="https://jsd.cdn.zzko.cn/gh/CodeByZach/pace/themes/green/pace-theme-flash.css"><script src="https://jsd.cdn.zzko.cn/npm/pace-js/pace.min.js"></script><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="https://jsd.cdn.zzko.cn/gh/ccknbc-backup/cdn/logo/logo.png" onerror='onerror=null,src="https://jsd.cdn.zzko.cn/npm/hexo-theme-anzhiyu/source/img/404.jpg"' alt="avatar"></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">38</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">7</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">7</div></a></div><hr class="custom-hr"><div class="menus_items"><div class="menus_item"><span class="site-page group"><i class="fa-fw fa-solid fa-book-reader"></i><span> 文章</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fa-solid fa-box-archive"></i><span> 归档</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fa-solid fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fa-solid fa-folder-open"></i><span> 分类</span></a></li></ul></div><div class="menus_item"><span class="site-page group"><i class="fa-fw fa-solid fa-cubes"></i><span> 社交</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/blogroll/"><i class="fa-fw fa-solid fa-link"></i><span> 友链</span></a></li><li><a class="site-page child" href="/moments/"><i class="fa-fw fa-solid fa-blog"></i><span> 友圈</span></a></li><li><a class="site-page child" href="/music/"><i class="fa-fw fa-solid fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/essay/"><i class="fa-fw fa-solid fa-comment-alt"></i><span> 短文</span></a></li></ul></div><div class="menus_item"><span class="site-page group"><i class="fa-fw fa-solid fa-desktop"></i><span> 关于</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/sub/"><i class="fa-fw fa-solid fa-bell"></i><span> 订阅</span></a></li><li><a class="site-page child" href="/about/"><i class="fa-fw fa-solid fa-list-check"></i><span> 本站</span></a></li><li><a class="site-page child" href="/privacy-policy/"><i class="fa-fw fa-solid fa-user-secret"></i><span> 隐私</span></a></li><li><a class="site-page child" target="_blank" rel="noopener external nofollow noreferrer" href="https://cc.instatus.com"><i class="fa-fw fa-solid fa-server"></i><span> 状态</span></a></li></ul></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image:url(https://pic1.afdiancdn.com/user/8a7f563c2e3811ecab5852540025c377/common/721e476cb2661152b9c43621c94e3ed7_w1366_h768_s86.png)"><nav id="nav"><span id="blog-info"><a href="/" title="CC的部落格"><span class="site-name">CC的部落格</span></a></span><div id="menus"><div id="search-button"><span class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></span></div><div class="menus_items"><div class="menus_item"><span class="site-page group"><i class="fa-fw fa-solid fa-book-reader"></i><span> 文章</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fa-solid fa-box-archive"></i><span> 归档</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fa-solid fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fa-solid fa-folder-open"></i><span> 分类</span></a></li></ul></div><div class="menus_item"><span class="site-page group"><i class="fa-fw fa-solid fa-cubes"></i><span> 社交</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/blogroll/"><i class="fa-fw fa-solid fa-link"></i><span> 友链</span></a></li><li><a class="site-page child" href="/moments/"><i class="fa-fw fa-solid fa-blog"></i><span> 友圈</span></a></li><li><a class="site-page child" href="/music/"><i class="fa-fw fa-solid fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/essay/"><i class="fa-fw fa-solid fa-comment-alt"></i><span> 短文</span></a></li></ul></div><div class="menus_item"><span class="site-page group"><i class="fa-fw fa-solid fa-desktop"></i><span> 关于</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/sub/"><i class="fa-fw fa-solid fa-bell"></i><span> 订阅</span></a></li><li><a class="site-page child" href="/about/"><i class="fa-fw fa-solid fa-list-check"></i><span> 本站</span></a></li><li><a class="site-page child" href="/privacy-policy/"><i class="fa-fw fa-solid fa-user-secret"></i><span> 隐私</span></a></li><li><a class="site-page child" target="_blank" rel="noopener external nofollow noreferrer" href="https://cc.instatus.com"><i class="fa-fw fa-solid fa-server"></i><span> 状态</span></a></li></ul></div></div><div id="toggle-menu"><span class="site-page"><i class="fas fa-bars fa-fw"></i></span></div></div></nav><div id="post-info"><h1 class="post-title">语雀文章同步至Hexo笔记</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-10-04T08:00:00.000Z" title="发表于 2022-10-04 16:00:00">2022-10-04</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-10-04T08:00:00.000Z" title="更新于 2022-10-04 16:00:00">2022-10-04</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E5%8D%9A%E5%AE%A2/">博客</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">3.5k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>13分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" data-flag-title="语雀文章同步至Hexo笔记"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><div class="post-ai-description"><div class="ai-title"><i class="fa-solid fa-newspaper"></i><div class="ai-title-text">AI-摘要</div><div id="ai-Toggle" title="CC/Tianli 模式切换">切换</div><i class="fa-solid fa-podcast" title="Tianli 模式下朗读摘要"></i><i class="fa-solid fa-arrow-rotate-right" title="Tianli 模式下刷新摘要"></i><div id="ai-tag">Tianli GPT</div></div><div class="ai-explanation">AI初始化中...</div><div class="ai-btn-box"><div class="ai-btn-item">介绍自己 🙈</div><div class="ai-btn-item">生成摘要 👋</div><div class="ai-btn-item">相关推荐 📖</div><div class="ai-btn-item">前往主页 🏠</div><div class="ai-btn-item" id="go-tianli-blog">前往爱发电购买</div></div><script data-pjax src="/"></script></div><article class="post-content" id="article-container"><p>查看本文<a target="_blank" rel="noopener external nofollow noreferrer" href="https://www.yuque.com/ccknbc/blog/36/"><strong>语雀</strong></a>版本【首发】，自动同步更新至<a href="https://blog.ccknbc.cc/posts/yuque-to-hexo/"><strong>CC 的部落格</strong></a>！</p><p><strong>建议直接查看结尾，新项目！但本文中的思路仍可借鉴，缓存缩小到了 1/12！</strong></p><p>因为 CC 已经使用语雀有一段时间了，但是因为使用的是 <code>GitHub Actions</code> 的原因，一直没有做什么更新，但是目前<code>json</code>已经 10M 了，是时候给缓存找一个地方存档以便后续增量更新了其实最开始的时候是直接推送到仓库的，后来有想过推送到<code>npm</code>的想法，但因为更新不怎么频繁也就一直耽搁了，但是因为不在使用条款范围内，有一定的风险，所以还是放弃了。在国庆前我就有想法传到<code>One Drive</code>这样的网盘，但是还是不是很方便，最好有现成的脚本可以使用。于是我想到了<code>Artifacts</code>构建产物这个东西，我只要先预先生成一次产物，然后下次就能把之前的产物下载下来使用，</p><p><img src= "" data-lazy-src="https://cdn.nlark.com/yuque/0/2022/png/8391407/1664898122389-f0faa9c8-3c46-4e71-b22b-5d8f20fd33b1.png#averageHue=%2311161d&amp;clientId=u9c173c7f-fbcf-4&amp;errorMessage=unknown%20error&amp;from=paste&amp;height=367&amp;id=u393e0845&amp;originHeight=459&amp;originWidth=1557&amp;originalType=binary&amp;ratio=1&amp;rotation=0&amp;showTitle=false&amp;size=73818&amp;status=error&amp;style=none&amp;taskId=ud01054b4-54f0-444b-a2d8-44b04cd20fc&amp;title=&amp;width=1245.6" alt="image.png" loading="lazy"> <img src= "" data-lazy-src="https://cdn.nlark.com/yuque/0/2022/png/8391407/1664898167865-16dcd66c-6e28-4ce6-a425-794de377cf67.png#averageHue=%230f131a&amp;clientId=u9c173c7f-fbcf-4&amp;errorMessage=unknown%20error&amp;from=paste&amp;height=242&amp;id=uc1d7e66c&amp;originHeight=303&amp;originWidth=582&amp;originalType=binary&amp;ratio=1&amp;rotation=0&amp;showTitle=false&amp;size=12922&amp;status=error&amp;style=none&amp;taskId=u1721969d-132c-4dcb-90b2-f441c3140ae&amp;title=&amp;width=465.6" alt="image.png" loading="lazy"></p><h2 id="关于工作流程构件">关于工作流程构件<a class="fa-solid fa-hashtag" href="#关于工作流程构件"></a></h2><p>构件允许您在作业完成后保留数据，并与同一工作流程中的另一个作业共享该数据。 构件是指在工作流程运行过程中产生的文件或文件集。 例如，在工作流程运行结束后，您可以使用构件保存您的构建和测试输出。 All actions and workflows called within a run have write access to that run’s artifacts.</p><p>默认情况下，GitHub 会将构建日志和项目存储 90 天（对于源码公开的我，公共仓库是完全够用的，只要保证 90 天更新一次博客即可），此保留期可以自定义。 有关详细信息，请参阅“<a target="_blank" rel="noopener external nofollow noreferrer" href="https://docs.github.com/cn/actions/reference/usage-limits-billing-and-administration#artifact-and-log-retention-policy">使用限制、计费和管理</a>”。 每当有人向拉取请求推送新提交时，拉取请求的保留期都会重新开始计算。</p><p>以下是您可以上传的一些常见构件：</p><ul><li>日志文件和核心转储文件</li><li>测试结果、失败和屏幕截图</li><li>二进制或压缩文件</li><li>压力测试性能输出和代码覆盖结果</li></ul><p>存储构件时使用存储空间 GitHub。 GitHub Actions usage is free for standard GitHub-hosted runners in public repositories, and for self-hosted runners. For private repositories, each GitHub account receives a certain amount of free minutes and storage for use with GitHub-hosted runners, depending on the product used with the account. Any usage beyond the included amounts is controlled by spending limits. 有关详细信息，请参阅“<a target="_blank" rel="noopener external nofollow noreferrer" href="https://docs.github.com/cn/billing/managing-billing-for-github-actions">GitHub Actions 的计费</a>”。</p><p>构件会在工作流程运行过程中上传，您可以在 UI 中查看构件的名称和大小。 当构件使用 GitHub UI 下载时， 作为构件一部分单独上传的所有文件都会压缩到一个 zip 文件中。 这意味着计费是根据上传的构件大小而不是 zip 文件的大小计算的。</p><p>GitHub 提供两项可用于上传和下载构建构件的操作。 有关详细信息，请参阅 <a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/actions/upload-artifact">actions/upload-artifact</a> 和 <a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/actions/download-artifact">download-artifact</a> 操作。</p><p>要在作业之间共享数据：</p><ul><li><strong>上传文件</strong>：为上传的文件指定一个名称，并在作业结束前上传数据。</li><li><strong>下载文件</strong>：只能下载在同一工作流运行期间上传的工件。 下载文件时，您可以通过名称引用该文件。</li></ul><p>作业步骤共享运行器机器的相同环境，但在其各自的进程中运行。 要在作业的步骤之间传递数据，您可以使用输入和输出。 有关输入和输出的详细信息，请参阅“<a target="_blank" rel="noopener external nofollow noreferrer" href="https://docs.github.com/cn/articles/metadata-syntax-for-github-actions">GitHub Actions 的元数据语法</a>”。</p><h2 id="比较构件和依赖项缓存">比较构件和依赖项缓存<a class="fa-solid fa-hashtag" href="#比较构件和依赖项缓存"></a></h2><p>构件与缓存类似，因为它们能够在 GitHub 上存储文件，但每项功能都提供不同的用例，不能互换使用。</p><ul><li>当想要重复使用在作业或工作流运行之间不频繁更改的文件时（例如从程序包管理系统构建依赖项），请使用缓存。</li><li>如果要保存作业生成的文件，以在工作流运行结束后查看（例如生成的二进制文件或生成日志），请使用项目。</li></ul><p>有关依赖项缓存的详细信息，请参阅“<a target="_blank" rel="noopener external nofollow noreferrer" href="https://docs.github.com/cn/actions/using-workflows/caching-dependencies-to-speed-up-workflows#comparing-artifacts-and-dependency-caching">缓存依赖项以加快工作流</a>”。</p><h2 id="上传构建和测试构件">上传构建和测试构件<a class="fa-solid fa-hashtag" href="#上传构建和测试构件"></a></h2><p>您可以创建持续集成 (CI) 工作流程来构建和测试您的代码。 有关使用 GitHub Actions 执行 CI 的详细信息，请参阅“<a target="_blank" rel="noopener external nofollow noreferrer" href="https://docs.github.com/cn/articles/about-continuous-integration">关于持续集成</a>”。</p><p>构建和测试代码的输出通常会生成可用于调试测试失败的文件和可部署的生产代码。 您可以配置一个工作流程来构建和测试推送到仓库中的代码，并报告成功或失败状态。 您可以上传构建和测试输出，以用于部署、调试失败的测试或崩溃以及查看测试套件范围。</p><p>可以使用 <code>upload-artifact</code> 操作上传工件。 上传构件时，您可以指定单个文件或目录，或多个文件或目录。 您还可以排除某些文件或目录，以及使用通配符模式。 建议为工件命名，如果没有命名，则会使用 <code>artifact</code> 作为默认名称。 有关语法的详细信息，请参阅 <a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/actions/upload-artifact">actions/upload-artifact</a> 操作。</p><h3 id="示例">示例<a class="fa-solid fa-hashtag" href="#示例"></a></h3><p>例如，您的仓库或 Web 应用程序可能包含必须转换为 CSS 和 JavaScript 的 SASS 和 TypeScript 文件。 假设生成配置输出 <code>dist</code> 目录中已编译的文件，如果所有测试均已成功完成，则可将 <code>dist</code> 目录中的文件部署到 Web 应用服务器。</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">|-- hello-world (repository)</span><br><span class="line">|   └── dist</span><br><span class="line">|   └── tests</span><br><span class="line">|   └── src</span><br><span class="line">|       └── sass/app.scss</span><br><span class="line">|       └── app.ts</span><br><span class="line">|   └── output</span><br><span class="line">|       └── test</span><br><span class="line">|</span><br></pre></td></tr></table></figure><p>此示例演示了如何创建 Node.js 项目的工作流，该项目在 <code>src</code> 目录中生成代码，在 <code>tests</code> 目录中运行测试。 可以假定运行 <code>npm test</code> 会生成一个名为 <code>code-coverage.html</code>、存储在 <code>output/test/</code> 目录中的代码覆盖率报告。</p><p>工作流上传 <code>dist</code> 目录中的生产工件，但不包括任何 Markdown 文件。 它还将 <code>code-coverage.html</code> 报表作为另一个工件上传。</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">name:</span> <span class="string">Node</span> <span class="string">CI</span></span><br><span class="line"></span><br><span class="line"><span class="attr">on:</span> [<span class="string">push</span>]</span><br><span class="line"></span><br><span class="line"><span class="attr">jobs:</span></span><br><span class="line">  <span class="attr">build_and_test:</span></span><br><span class="line">    <span class="attr">runs-on:</span> <span class="string">ubuntu-latest</span></span><br><span class="line">    <span class="attr">steps:</span></span><br><span class="line">      <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Checkout</span> <span class="string">repository</span></span><br><span class="line">        <span class="attr">uses:</span> <span class="string">actions/checkout@v3</span></span><br><span class="line">      <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">npm</span> <span class="string">install,</span> <span class="string">build,</span> <span class="string">and</span> <span class="string">test</span></span><br><span class="line">        <span class="attr">run:</span> <span class="string">|</span></span><br><span class="line"><span class="string">          npm install</span></span><br><span class="line"><span class="string">          npm run build --if-present</span></span><br><span class="line"><span class="string">          npm test</span></span><br><span class="line"><span class="string"></span>      <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Archive</span> <span class="string">production</span> <span class="string">artifacts</span></span><br><span class="line">        <span class="attr">uses:</span> <span class="string">actions/upload-artifact@v3</span></span><br><span class="line">        <span class="attr">with:</span></span><br><span class="line">          <span class="attr">name:</span> <span class="string">dist-without-markdown</span></span><br><span class="line">          <span class="attr">path:</span> <span class="string">|</span></span><br><span class="line"><span class="string">            dist</span></span><br><span class="line"><span class="string">            !dist/**/*.md</span></span><br><span class="line"><span class="string"></span>      <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Archive</span> <span class="string">code</span> <span class="string">coverage</span> <span class="string">results</span></span><br><span class="line">        <span class="attr">uses:</span> <span class="string">actions/upload-artifact@v3</span></span><br><span class="line">        <span class="attr">with:</span></span><br><span class="line">          <span class="attr">name:</span> <span class="string">code-coverage-report</span></span><br><span class="line">          <span class="attr">path:</span> <span class="string">output/test/code-coverage.html</span></span><br></pre></td></tr></table></figure><h2 id="配置自定义构件保留期">配置自定义构件保留期<a class="fa-solid fa-hashtag" href="#配置自定义构件保留期"></a></h2><p>您可以为工作流程创建的单个构件自定义保留期。 使用工作流创建新工件时，可以同时使用 <code>retention-days</code> 和 <code>upload-artifact</code> 操作。 此示例演示如何为名为 <code>my-artifact</code> 的工件设置 5 天的自定义保留期：</p><p><code>retention-days</code> 值不能超过存储库、组织或企业设置的保留限制。</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="bullet">-</span> <span class="attr">name:</span> <span class="string">&quot;Upload Artifact&quot;</span></span><br><span class="line">  <span class="attr">uses:</span> <span class="string">actions/upload-artifact@v3</span></span><br><span class="line">  <span class="attr">with:</span></span><br><span class="line">    <span class="attr">name:</span> <span class="string">my-artifact</span></span><br><span class="line">    <span class="attr">path:</span> <span class="string">my_file.txt</span></span><br><span class="line">    <span class="attr">retention-days:</span> <span class="number">5</span></span><br></pre></td></tr></table></figure><h2 id="下载或删除构件">下载或删除构件<a class="fa-solid fa-hashtag" href="#下载或删除构件"></a></h2><p>在工作流运行期间，可以使用 <a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/actions/download-artifact">actions/download-artifact</a>操作下载以前在同一工作流运行中上传的工件。</p><p>工作流程运行完成后，您可以在 GitHub 上或使用 REST API 下载或删除构件。 有关详细信息，请参阅“<a target="_blank" rel="noopener external nofollow noreferrer" href="https://docs.github.com/cn/actions/managing-workflow-runs/downloading-workflow-artifacts">下载工作流工件</a>”、“<a target="_blank" rel="noopener external nofollow noreferrer" href="https://docs.github.com/cn/actions/managing-workflow-runs/removing-workflow-artifacts">删除工作流工件</a>”和“<a target="_blank" rel="noopener external nofollow noreferrer" href="https://docs.github.com/cn/rest/reference/actions#artifacts">工件 REST API</a>”。</p><h3 id="在工作流程运行期间下载构件">在工作流程运行期间下载构件<a class="fa-solid fa-hashtag" href="#在工作流程运行期间下载构件"></a></h3><p><a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/actions/download-artifact">actions/download-artifact</a>操作可用于在工作流运行期间下载以前上传的工件。</p><blockquote><p>注意：只能下载在同一工作流运行期间上传的工作流中的工件。</p></blockquote><p>指定构件的名称以下载单个构件。 如果在未指定名称的情况下上传了工件，则默认名称为 <code>artifact</code>。</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Download</span> <span class="string">a</span> <span class="string">single</span> <span class="string">artifact</span></span><br><span class="line">  <span class="attr">uses:</span> <span class="string">actions/download-artifact@v3</span></span><br><span class="line">  <span class="attr">with:</span></span><br><span class="line">    <span class="attr">name:</span> <span class="string">my-artifact</span></span><br></pre></td></tr></table></figure><p>您还可以不指定名称而下载工作流程运行中的所有构件。 如果您在处理大量构件，此功能非常有用。</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Download</span> <span class="string">all</span> <span class="string">workflow</span> <span class="string">run</span> <span class="string">artifacts</span></span><br><span class="line">  <span class="attr">uses:</span> <span class="string">actions/download-artifact@v3</span></span><br></pre></td></tr></table></figure><p>如果下载所有工作流运行的工件，则会为每个工件使用其名称创建一个目录。</p><p>有关语法的详细信息，请参阅 <a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/actions/download-artifact">actions/download-artifact</a> 操作。</p><h2 id="在工作流中的作业间传递数据">在工作流中的作业间传递数据<a class="fa-solid fa-hashtag" href="#在工作流中的作业间传递数据"></a></h2><p>可以使用 <code>upload-artifact</code> 和 <code>download-artifact</code> 操作在工作流中的作业间共享数据。 此示例工作流程说明如何在相同工作流程中的任务之间传递数据。 有关详细信息，请参阅 <a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/actions/upload-artifact">actions/upload-artifact</a> 和 <a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/actions/download-artifact">download-artifact</a> 操作。</p><p>依赖于以前作业构件的作业必须等待依赖项成功完成。 此工作流使用 <code>needs</code> 密钥来确保 <code>job_1</code>、<code>job_2</code> 和 <code>job_3</code> 按顺序运行。 例如，<code>job_2</code> 需要 <code>job_1</code>，方法是使用 <code>needs: job_1</code> 语法。</p><p>作业 1 执行以下步骤：</p><ul><li>执行数学计算并将结果保存到名为 <code>math-homework.txt</code> 的文本文件。</li><li>使用 <code>upload-artifact</code> 操作上传工件名称为 <code>homework</code> 的 <code>math-homework.txt</code> 文件。</li></ul><p>作业 2 使用上一个作业的结果：</p><ul><li>下载在上一作业中上传的 <code>homework</code> 工件。 默认情况下，<code>download-artifact</code> 操作会将工件下载到该步骤执行的工作区目录中。 可以使用 <code>path</code> 输入参数指定不同的下载目录。</li><li>读取 <code>math-homework.txt</code> 文件中的值，执行数学计算，并再次将结果保存到 <code>math-homework.txt</code>，覆盖其内容。</li><li>上传 <code>math-homework.txt</code> 文件。 此上传会覆盖之前上传的构件，因为它们共用同一名称。</li></ul><p>作业 3 显示上一个作业中上传的结果：</p><ul><li>下载 <code>homework</code> 工件。</li><li>将数学方程式的结果打印到日志中。</li></ul><p>在此工作流示例中执行的完整数学运算是 <code>(3 + 7) x 9 = 90</code>，工作流程运行运行将会存档它生成的任何构件。</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">name:</span> <span class="string">Share</span> <span class="string">data</span> <span class="string">between</span> <span class="string">jobs</span></span><br><span class="line"></span><br><span class="line"><span class="attr">on:</span> [<span class="string">push</span>]</span><br><span class="line"></span><br><span class="line"><span class="attr">jobs:</span></span><br><span class="line">  <span class="attr">job_1:</span></span><br><span class="line">    <span class="attr">name:</span> <span class="string">Add</span> <span class="number">3</span> <span class="string">and</span> <span class="number">7</span></span><br><span class="line">    <span class="attr">runs-on:</span> <span class="string">ubuntu-latest</span></span><br><span class="line">    <span class="attr">steps:</span></span><br><span class="line">      <span class="bullet">-</span> <span class="attr">shell:</span> <span class="string">bash</span></span><br><span class="line">        <span class="attr">run:</span> <span class="string">|</span></span><br><span class="line"><span class="string">          expr 3 + 7 &gt; math-homework.txt</span></span><br><span class="line"><span class="string"></span>      <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Upload</span> <span class="string">math</span> <span class="string">result</span> <span class="string">for</span> <span class="string">job</span> <span class="number">1</span></span><br><span class="line">        <span class="attr">uses:</span> <span class="string">actions/upload-artifact@v3</span></span><br><span class="line">        <span class="attr">with:</span></span><br><span class="line">          <span class="attr">name:</span> <span class="string">homework</span></span><br><span class="line">          <span class="attr">path:</span> <span class="string">math-homework.txt</span></span><br><span class="line"></span><br><span class="line">  <span class="attr">job_2:</span></span><br><span class="line">    <span class="attr">name:</span> <span class="string">Multiply</span> <span class="string">by</span> <span class="number">9</span></span><br><span class="line">    <span class="attr">needs:</span> <span class="string">job_1</span></span><br><span class="line">    <span class="attr">runs-on:</span> <span class="string">windows-latest</span></span><br><span class="line">    <span class="attr">steps:</span></span><br><span class="line">      <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Download</span> <span class="string">math</span> <span class="string">result</span> <span class="string">for</span> <span class="string">job</span> <span class="number">1</span></span><br><span class="line">        <span class="attr">uses:</span> <span class="string">actions/download-artifact@v3</span></span><br><span class="line">        <span class="attr">with:</span></span><br><span class="line">          <span class="attr">name:</span> <span class="string">homework</span></span><br><span class="line">      <span class="bullet">-</span> <span class="attr">shell:</span> <span class="string">bash</span></span><br><span class="line">        <span class="attr">run:</span> <span class="string">|</span></span><br><span class="line"><span class="string">          value=`cat math-homework.txt`</span></span><br><span class="line"><span class="string">          expr $value \* 9 &gt; math-homework.txt</span></span><br><span class="line"><span class="string"></span>      <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Upload</span> <span class="string">math</span> <span class="string">result</span> <span class="string">for</span> <span class="string">job</span> <span class="number">2</span></span><br><span class="line">        <span class="attr">uses:</span> <span class="string">actions/upload-artifact@v3</span></span><br><span class="line">        <span class="attr">with:</span></span><br><span class="line">          <span class="attr">name:</span> <span class="string">homework</span></span><br><span class="line">          <span class="attr">path:</span> <span class="string">math-homework.txt</span></span><br><span class="line"></span><br><span class="line">  <span class="attr">job_3:</span></span><br><span class="line">    <span class="attr">name:</span> <span class="string">Display</span> <span class="string">results</span></span><br><span class="line">    <span class="attr">needs:</span> <span class="string">job_2</span></span><br><span class="line">    <span class="attr">runs-on:</span> <span class="string">macOS-latest</span></span><br><span class="line">    <span class="attr">steps:</span></span><br><span class="line">      <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Download</span> <span class="string">math</span> <span class="string">result</span> <span class="string">for</span> <span class="string">job</span> <span class="number">2</span></span><br><span class="line">        <span class="attr">uses:</span> <span class="string">actions/download-artifact@v3</span></span><br><span class="line">        <span class="attr">with:</span></span><br><span class="line">          <span class="attr">name:</span> <span class="string">homework</span></span><br><span class="line">      <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Print</span> <span class="string">the</span> <span class="string">final</span> <span class="string">result</span></span><br><span class="line">        <span class="attr">shell:</span> <span class="string">bash</span></span><br><span class="line">        <span class="attr">run:</span> <span class="string">|</span></span><br><span class="line"><span class="string">          value=`cat math-homework.txt`</span></span><br><span class="line"><span class="string">          echo The result is $value</span></span><br></pre></td></tr></table></figure><h2 id="踩坑记录">踩坑记录<a class="fa-solid fa-hashtag" href="#踩坑记录"></a></h2><p>首先看看我的工作流文件，处理部分代码，会发现有一些疑问，怎么和文档提到的不太一样</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">name:</span> <span class="string">Deploy</span> <span class="string">Yuque-Hexo</span> <span class="string">Public</span> <span class="string">To</span> <span class="string">Pages</span></span><br><span class="line"></span><br><span class="line"><span class="attr">on:</span></span><br><span class="line">  <span class="attr">repository_dispatch:</span></span><br><span class="line">  <span class="attr">workflow_dispatch:</span></span><br><span class="line">  <span class="attr">push:</span></span><br><span class="line">    <span class="attr">branches:</span> <span class="string">master</span></span><br><span class="line"></span><br><span class="line"><span class="attr">jobs:</span></span><br><span class="line">  <span class="attr">deploy:</span></span><br><span class="line">    <span class="attr">name:</span> <span class="string">Deploy</span> <span class="string">Yuque-Hexo</span> <span class="string">Public</span> <span class="string">To</span> <span class="string">Pages</span></span><br><span class="line">    <span class="attr">runs-on:</span> <span class="string">ubuntu-latest</span></span><br><span class="line">    <span class="attr">env:</span></span><br><span class="line">      <span class="attr">TZ:</span> <span class="string">Asia/Shanghai</span></span><br><span class="line">      <span class="attr">ALGOLIA_ADMIN_API_KEY:</span> <span class="string">$&#123;&#123;</span> <span class="string">secrets.ALGOLIA_ADMIN_API_KEY</span> <span class="string">&#125;&#125;</span></span><br><span class="line">      <span class="attr">YUQUE_TOKEN:</span> <span class="string">$&#123;&#123;</span> <span class="string">secrets.YUQUE_TOKEN</span> <span class="string">&#125;&#125;</span></span><br><span class="line">      <span class="attr">webpushrKey:</span> <span class="string">$&#123;&#123;</span> <span class="string">secrets.WEBPUSHR_KEY</span> <span class="string">&#125;&#125;</span></span><br><span class="line">      <span class="attr">webpushrAuthToken:</span> <span class="string">$&#123;&#123;</span> <span class="string">secrets.WEBPUSHR_AUTH_TOKEN</span> <span class="string">&#125;&#125;</span></span><br><span class="line"></span><br><span class="line">    <span class="attr">steps:</span></span><br><span class="line">      <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Checkout</span></span><br><span class="line">        <span class="attr">uses:</span> <span class="string">actions/checkout@main</span></span><br><span class="line">        <span class="attr">with:</span></span><br><span class="line">          <span class="attr">ref:</span> <span class="string">master</span></span><br><span class="line">          <span class="attr">fetch-depth:</span> <span class="number">0</span></span><br><span class="line"></span><br><span class="line">      <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Setup</span> <span class="string">Node</span></span><br><span class="line">        <span class="attr">uses:</span> <span class="string">actions/setup-node@main</span></span><br><span class="line">        <span class="attr">id:</span> <span class="string">setup-node</span></span><br><span class="line">        <span class="attr">with:</span></span><br><span class="line">          <span class="attr">node-version:</span> <span class="string">&quot;latest&quot;</span></span><br><span class="line">          <span class="attr">check-latest:</span> <span class="literal">true</span></span><br><span class="line">          <span class="attr">cache:</span> <span class="string">&quot;npm&quot;</span></span><br><span class="line"></span><br><span class="line">      <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Catch</span> <span class="string">Dependencies</span></span><br><span class="line">        <span class="attr">uses:</span> <span class="string">actions/cache@main</span></span><br><span class="line">        <span class="attr">id:</span> <span class="string">cache-dependencies</span></span><br><span class="line">        <span class="attr">with:</span></span><br><span class="line">          <span class="attr">path:</span> <span class="string">node_modules</span></span><br><span class="line">          <span class="attr">key:</span> <span class="string">$&#123;&#123;runner.OS&#125;&#125;-$&#123;&#123;hashFiles(&#x27;**/package-lock.json&#x27;)&#125;&#125;</span></span><br><span class="line"></span><br><span class="line">      <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Install</span> <span class="string">Dependencies</span></span><br><span class="line">        <span class="attr">if:</span> <span class="string">steps.cache-dependencies.outputs.cache-hit</span> <span class="type">!=</span> <span class="string">&#x27;true&#x27;</span></span><br><span class="line">        <span class="attr">run:</span> <span class="string">|</span></span><br><span class="line"><span class="string">          npm ci</span></span><br><span class="line"><span class="string"></span></span><br><span class="line">      <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Download</span> <span class="string">Yuque</span> <span class="string">Posts</span></span><br><span class="line">        <span class="attr">uses:</span> <span class="string">dawidd6/action-download-artifact@v2</span></span><br><span class="line">        <span class="attr">with:</span></span><br><span class="line">          <span class="attr">github_token:</span> <span class="string">$&#123;&#123;secrets.GITHUB_TOKEN&#125;&#125;</span></span><br><span class="line">          <span class="attr">name:</span> <span class="string">&quot;Yuque Posts&quot;</span></span><br><span class="line">          <span class="attr">path:</span> <span class="string">&quot;source/_posts&quot;</span></span><br><span class="line"></span><br><span class="line">      <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Download</span> <span class="string">Yuque</span> <span class="string">Cache</span></span><br><span class="line">        <span class="attr">uses:</span> <span class="string">dawidd6/action-download-artifact@v2</span></span><br><span class="line">        <span class="attr">with:</span></span><br><span class="line">          <span class="attr">github_token:</span> <span class="string">$&#123;&#123;secrets.GITHUB_TOKEN&#125;&#125;</span></span><br><span class="line">          <span class="attr">name:</span> <span class="string">&quot;Yuque Cache&quot;</span></span><br><span class="line">          <span class="attr">path:</span> <span class="string">&quot;yuque&quot;</span></span><br><span class="line"></span><br><span class="line">      <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Generate</span></span><br><span class="line">        <span class="attr">run:</span> <span class="string">|</span></span><br><span class="line"><span class="string">          npm i -g hexo-cli yuque-hexo</span></span><br><span class="line"><span class="string">          npm run yuque</span></span><br><span class="line"><span class="string"></span>        <span class="comment"># npm i -g hexo-cli yuque-hexo</span></span><br><span class="line">        <span class="comment"># mkdir yuque</span></span><br><span class="line">        <span class="comment"># yuque-hexo sync</span></span><br><span class="line"></span><br><span class="line">      <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Upload</span> <span class="string">Yuque</span> <span class="string">Cache</span></span><br><span class="line">        <span class="attr">uses:</span> <span class="string">actions/upload-artifact@v3</span></span><br><span class="line">        <span class="attr">with:</span></span><br><span class="line">          <span class="attr">name:</span> <span class="string">&quot;Yuque Cache&quot;</span></span><br><span class="line">          <span class="attr">path:</span> <span class="string">yuque</span></span><br><span class="line">          <span class="attr">retention-days:</span> <span class="number">90</span></span><br><span class="line"></span><br><span class="line">      <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Upload</span> <span class="string">Yuque</span> <span class="string">Posts</span></span><br><span class="line">        <span class="attr">uses:</span> <span class="string">actions/upload-artifact@v3</span></span><br><span class="line">        <span class="attr">with:</span></span><br><span class="line">          <span class="attr">name:</span> <span class="string">&quot;Yuque Posts&quot;</span></span><br><span class="line">          <span class="attr">path:</span> <span class="string">&quot;source/_posts&quot;</span></span><br><span class="line">          <span class="attr">retention-days:</span> <span class="number">90</span></span><br></pre></td></tr></table></figure><p>如果配合<code>package.json</code>看是不是就明显多了</p><figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">  <span class="attr">&quot;name&quot;</span><span class="punctuation">:</span> <span class="string">&quot;ccknbc-blog&quot;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;version&quot;</span><span class="punctuation">:</span> <span class="string">&quot;latest&quot;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;private&quot;</span><span class="punctuation">:</span> <span class="literal"><span class="keyword">false</span></span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;type&quot;</span><span class="punctuation">:</span> <span class="string">&quot;module&quot;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;scripts&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;build&quot;</span><span class="punctuation">:</span> <span class="string">&quot;hexo generate&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;clean&quot;</span><span class="punctuation">:</span> <span class="string">&quot;hexo clean&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;deploy&quot;</span><span class="punctuation">:</span> <span class="string">&quot;hexo deploy&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;server&quot;</span><span class="punctuation">:</span> <span class="string">&quot;hexo server&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;yuque&quot;</span><span class="punctuation">:</span> <span class="string">&quot;yuque-hexo sync &amp;&amp; npm run build &amp;&amp; hexo algolia &amp;&amp; npm run deploy&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;github&quot;</span><span class="punctuation">:</span> <span class="string">&quot;npm run build &amp;&amp; hexo algolia &amp;&amp; npm run deploy&quot;</span></span><br><span class="line">  <span class="punctuation">&#125;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;yuqueConfig&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;postPath&quot;</span><span class="punctuation">:</span> <span class="string">&quot;/source/_posts/语雀&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;cachePath&quot;</span><span class="punctuation">:</span> <span class="string">&quot;/yuque/cache.json&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;lastGeneratePath&quot;</span><span class="punctuation">:</span> <span class="string">&quot;/yuque/lastGeneratePath.log&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;mdNameFormat&quot;</span><span class="punctuation">:</span> <span class="string">&quot;title&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;adapter&quot;</span><span class="punctuation">:</span> <span class="string">&quot;markdown&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;concurrency&quot;</span><span class="punctuation">:</span> <span class="string">&quot;5&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;timeout&quot;</span><span class="punctuation">:</span> <span class="string">&quot;100s&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;baseUrl&quot;</span><span class="punctuation">:</span> <span class="string">&quot;https://www.yuque.com/api/v2&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;login&quot;</span><span class="punctuation">:</span> <span class="string">&quot;ccknbc&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;repo&quot;</span><span class="punctuation">:</span> <span class="string">&quot;blog&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;onlyPublished&quot;</span><span class="punctuation">:</span> <span class="literal"><span class="keyword">true</span></span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;onlyPublic&quot;</span><span class="punctuation">:</span> <span class="literal"><span class="keyword">true</span></span></span><br><span class="line">  <span class="punctuation">&#125;</span><span class="punctuation">,</span></span><br></pre></td></tr></table></figure><p>具体实现思路如下：</p><ol><li>语雀缓存 json 及其时间戳我放在博客根目录<code>yuque</code>这个文件夹里，文章只要放在<code>/source/_posts/</code>下任意目录即可，子目录也行</li><li>上传脚本使用官方的就行，下载脚本得使用<a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/dawidd6/action-download-artifact">action-download-artifact</a>，原因上面也提到了，官方的脚本<code>只能下载在同一工作流运行期间上传的工作流中的工件</code>！而这位作者的脚本默认下载上次运行成功后构建的产物，完美符合我们的需求</li><li>第一次使用只保留上传脚本，注释掉下载脚本，因为没有已成功构建产物，此外在执行<code>yuque-hexo sync</code> 之前因为我没有放在根目录，所以还需要创建文件夹命令<code>mkdir -p yuque</code>否则会报错。后续使用取消注释掉的下载脚本，也可以取消这条命令了，因为加了判断，也可以不取消。</li><li>一定要注意文章放文章目录下，缓存放缓存目录下！不然 hexo 识别到这么大的专属格式<code>json</code>会解析报错卡在了<code>hexo g</code></li></ol><h2 id="后续更新">后续更新<a class="fa-solid fa-hashtag" href="#后续更新"></a></h2><p>由于原作者以放弃此项目，推荐使用他的新项目同步 <a target="_blank" rel="noopener external nofollow noreferrer" href="https://elog.1874.cool/">@Elog</a>，而使用示例也可查看<a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/ccknbc-actions/blog-butterfly">我的仓库</a></p></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://blog.ccknbc.cc/">CC康纳百川</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://blog.ccknbc.cc/posts/yuque-to-hexo/">https://blog.ccknbc.cc/posts/yuque-to-hexo/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a target="_blank" rel="noopener external nofollow noreferrer" href="https://creativecommons.org/licenses/by-nc-sa/4.0/"><i style="color:#8fbc8f" class="fa-brands fa-creative-commons"></i> <i style="color:#8fbc8f" class="fa-brands fa-creative-commons-by"></i> <i style="color:#8fbc8f" class="fa-brands fa-creative-commons-nc"></i> <i style="color:#8fbc8f" class="fa-brands fa-creative-commons-sa"></i> CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://blog.ccknbc.cc">CC的部落格</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E5%8D%9A%E5%AE%A2/">博客</a><a class="post-meta__tags" href="/tags/%E5%B7%A5%E5%85%B7/">工具</a></div><div class="post_share"><div class="social-share" data-image="https://pic1.afdiancdn.com/user/8a7f563c2e3811ecab5852540025c377/common/721e476cb2661152b9c43621c94e3ed7_w1366_h768_s86.png" data-sites="wechat,weibo,qq,facebook,twitter"></div><link rel="stylesheet" href="https://jsd.cdn.zzko.cn/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload='this.media="all"'><script src="https://jsd.cdn.zzko.cn/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i>赞赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="https://www.rocschool.com/tool/qr/qr/id/51.html" rel="external nofollow noreferrer" target="_blank"><img class="post-qr-code-img" src= "" data-lazy-src="https://jsd.cdn.zzko.cn/gh/ccknbc-backup/cdn/logo/qr.png" alt="三合一"></a><div class="post-qr-code-desc">三合一</div></li><li class="reward-item"><a href="https://afdian.net/@ccknbc" rel="external nofollow noreferrer" target="_blank"><img class="post-qr-code-img" src= "" data-lazy-src="https://jsd.cdn.zzko.cn/gh/ccknbc-backup/cdn/logo/afdian.png" alt="爱发电"></a><div class="post-qr-code-desc">爱发电</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/posts/about-pts/" title="你的公共电视"><img class="cover" src= "" data-lazy-src="https://pic1.afdiancdn.com/user/8a7f563c2e3811ecab5852540025c377/common/fa96706020ae1d6e9333e56be39b91f0_w1920_h1080_s75.jpg" onerror='onerror=null,src="https://jsd.cdn.zzko.cn/npm/hexo-theme-anzhiyu/source/img/friend_404.gif"' alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">你的公共电视</div></div></a></div><div class="next-post pull-right"><a href="/posts/hexo-webpushr-notification/" title="Hexo浏览器定向推送文章更新"><img class="cover" src= "" data-lazy-src="https://pic1.afdiancdn.com/user/8a7f563c2e3811ecab5852540025c377/common/d2a947d48815ed24936a919873b97841_w1366_h768_s31.png" onerror='onerror=null,src="https://jsd.cdn.zzko.cn/npm/hexo-theme-anzhiyu/source/img/friend_404.gif"' alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">Hexo浏览器定向推送文章更新</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/posts/hexo-webpushr-notification/" title="Hexo浏览器定向推送文章更新"><img class="cover" src= "" data-lazy-src="https://pic1.afdiancdn.com/user/8a7f563c2e3811ecab5852540025c377/common/d2a947d48815ed24936a919873b97841_w1366_h768_s31.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-10-05</div><div class="title">Hexo浏览器定向推送文章更新</div></div></a></div><div><a href="/posts/how-to-hide-hexo-articles-gracefully/" title="如何优雅隐藏 Hexo 文章"><img class="cover" src= "" data-lazy-src="https://pic1.afdiancdn.com/user/8a7f563c2e3811ecab5852540025c377/common/aa5ebc0731a66fa5fb73df76da759ae3_w1920_h1080_s557.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-10-22</div><div class="title">如何优雅隐藏 Hexo 文章</div></div></a></div><div><a href="/posts/google-adsense-configuration-manual/" title="Google Adsense 配置手册"><img class="cover" src= "" data-lazy-src="https://pic1.afdiancdn.com/user/8a7f563c2e3811ecab5852540025c377/common/0a77436f677dd11422579e07ba6423b3_w1920_h1080_s188.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-10-24</div><div class="title">Google Adsense 配置手册</div></div></a></div><div><a href="/posts/introduction-of-plugin-tags-based-on-butterfly/" title="Hexo标签笔记"><img class="cover" src= "" data-lazy-src="https://pic1.afdiancdn.com/user/8a7f563c2e3811ecab5852540025c377/common/666ccfeb387717d69a0e3333cc1170dc_w1004_h591_s48.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-03-05</div><div class="title">Hexo标签笔记</div></div></a></div><div><a href="/posts/the-webp-road-of-blog-pictures/" title="博客图片的 WebP 之路"><img class="cover" src= "" data-lazy-src="https://pic1.afdiancdn.com/user/8a7f563c2e3811ecab5852540025c377/common/a4d78fbe1ca6e99e19535a095681c5ba_w1920_h1080_s770.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-11-29</div><div class="title">博客图片的 WebP 之路</div></div></a></div><div><a href="/posts/hexo-toss/" title="HEXO 折腾"><img class="cover" src= "" data-lazy-src="https://pic1.afdiancdn.com/user/8a7f563c2e3811ecab5852540025c377/common/45d888bd81b86777b3364e4a16ff72c6_w2240_h1260_s476.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-07-01</div><div class="title">HEXO 折腾</div></div></a></div></div></div><hr class="custom-hr"><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div id="waline-wrap"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%85%B3%E4%BA%8E%E5%B7%A5%E4%BD%9C%E6%B5%81%E7%A8%8B%E6%9E%84%E4%BB%B6"><span class="toc-number">1.</span> <span class="toc-text">关于工作流程构件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%AF%94%E8%BE%83%E6%9E%84%E4%BB%B6%E5%92%8C%E4%BE%9D%E8%B5%96%E9%A1%B9%E7%BC%93%E5%AD%98"><span class="toc-number">2.</span> <span class="toc-text">比较构件和依赖项缓存</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%8A%E4%BC%A0%E6%9E%84%E5%BB%BA%E5%92%8C%E6%B5%8B%E8%AF%95%E6%9E%84%E4%BB%B6"><span class="toc-number">3.</span> <span class="toc-text">上传构建和测试构件</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%A4%BA%E4%BE%8B"><span class="toc-number">3.1.</span> <span class="toc-text">示例</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE%E8%87%AA%E5%AE%9A%E4%B9%89%E6%9E%84%E4%BB%B6%E4%BF%9D%E7%95%99%E6%9C%9F"><span class="toc-number">4.</span> <span class="toc-text">配置自定义构件保留期</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%8B%E8%BD%BD%E6%88%96%E5%88%A0%E9%99%A4%E6%9E%84%E4%BB%B6"><span class="toc-number">5.</span> <span class="toc-text">下载或删除构件</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%9C%A8%E5%B7%A5%E4%BD%9C%E6%B5%81%E7%A8%8B%E8%BF%90%E8%A1%8C%E6%9C%9F%E9%97%B4%E4%B8%8B%E8%BD%BD%E6%9E%84%E4%BB%B6"><span class="toc-number">5.1.</span> <span class="toc-text">在工作流程运行期间下载构件</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%9C%A8%E5%B7%A5%E4%BD%9C%E6%B5%81%E4%B8%AD%E7%9A%84%E4%BD%9C%E4%B8%9A%E9%97%B4%E4%BC%A0%E9%80%92%E6%95%B0%E6%8D%AE"><span class="toc-number">6.</span> <span class="toc-text">在工作流中的作业间传递数据</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%B8%A9%E5%9D%91%E8%AE%B0%E5%BD%95"><span class="toc-number">7.</span> <span class="toc-text">踩坑记录</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%90%8E%E7%BB%AD%E6%9B%B4%E6%96%B0"><span class="toc-number">8.</span> <span class="toc-text">后续更新</span></a></li></ol></div></div></div></div></main><footer id="footer" style="background:linear-gradient(135deg,#fff1eb,#ace0f9)"><div id="footer-wrap"><div class="icp"><a target="_blank" rel="noopener external nofollow noreferrer" href="https://beian.miit.gov.cn"><img class="icp-icon" src= "" data-lazy-src="https://jsd.cdn.zzko.cn/gh/ccknbc-backup/cdn/logo/icp.png" alt="ICP"><span>鄂 ICP 备 2020019764 号</span></a></div><div class="gongan"><a target="_blank" rel="noopener external nofollow noreferrer" href="https://www.beian.gov.cn/portal/registerSystemInfo?recordcode=42088102000092"><img class="gongan-icon" src= "" data-lazy-src="https://jsd.cdn.zzko.cn/gh/ccknbc-backup/cdn/logo/gongan.png" alt="gongan"><span>鄂公网安备 42088102000092 号</span></a></div><div class="live"><span>本站已运行</span><span id="display_live"></span><span class="moe-text">CCKNBC All Rights Reserved.</span><script>function blog_live(){window.setTimeout(blog_live,1e3);var e=new Date("2020-06-04T00:00:00"),o=new Date,l=o.getFullYear(),o=o.getTime()-e.getTime(),e=864e5,t=365*e,i=Math.floor(o/t),t=Math.floor(o%t/e),e=Math.floor(o%e/60/60/1e3),a=Math.floor(o%36e5/60/1e3),o=Math.floor(o%6e4/1e3);display_live.innerHTML=" "+i+" 年 "+t+" 天 "+e+" 小时 "+a+" 分 "+o+" 秒<br>&copy; 2020 - "+l+" "}blog_live()</script></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><a class="edit-yuque" target="_blank" rel="noopener external nofollow noreferrer" href="https://www.yuque.com/ccknbc/blog/36/edit/" title="在语雀上以富文本格式编辑/预览 - 语雀文章同步至Hexo笔记"><i class="fa-solid fa-crow"></i></a><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fa-solid fa-arrows-alt-h"></i></button><button id="readmode" type="button" title="阅读模式"><i class="fa-solid fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fa-solid fa-adjust"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fa-solid fa-cog"></i></button><button id="share-link" type="button" title="分享链接"><i class="fa-solid fa-share"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fa-solid fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fa-solid fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fa-solid fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://jsd.cdn.zzko.cn/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.js"></script><script src="https://jsd.cdn.zzko.cn/npm/instant.page/instantpage.js" type="module"></script><script src="https://jsd.cdn.zzko.cn/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="https://jsd.cdn.zzko.cn/npm/node-snackbar/dist/snackbar.min.js"></script><div class="js-pjax"><script>(()=>{var e=()=>{var e;const t=document.querySelectorAll("#article-container .mermaid-wrap");0!==t.length&&(e=()=>{{var e=t;window.loadMermaid=!0;const a="dark"===document.documentElement.getAttribute("data-theme")?"dark":"default";Array.from(e).forEach((e,t)=>{const n=e.firstElementChild;e="%%{init:{ 'theme':'"+a+"'}}%%\n"+n.textContent;const d=mermaid.render("mermaid-"+t,e);"string"==typeof d?(t=d,n.insertAdjacentHTML("afterend",t)):d.then(({svg:e})=>{n.insertAdjacentHTML("afterend",e)})})}},btf.addGlobalFn("themeChange",e,"mermaid"),window.loadMermaid?e():btf.getScript("https://jsd.cdn.zzko.cn/npm/mermaid/dist/mermaid.min.js").then(e))};btf.addGlobalFn("encrypt",e,"mermaid"),window.pjax?e():document.addEventListener("DOMContentLoaded",e)})()</script><script>(()=>{let n=window.walineFn||null;const t=e=>{const n=e(Object.assign({el:"#waline-wrap",serverURL:"https://waline.ccknbc.cc",pageview:!1,dark:'html[data-theme="dark"]',path:window.location.pathname,comment:!1,imageUploader:function(e){var n=new FormData,t=new Headers;return n.append("file",e),n.append("album_id","10"),n.append("permission","0"),t.append("Authorization","Bearer 24|o8Crl5y0oK3luyUs17fBxDtAcevk1iiLHVFMNjpA"),t.append("Accept","application/json"),fetch("https://wmimg.com/api/v1/upload",{method:"POST",headers:t,body:n}).then(e=>e.json()).then(e=>e.data.links.url)}},{pageSize:10,meta:["nick","mail","link"],requiredMeta:["nick","mail"],login:"force",copyright:!0,search:!0,turnstileKey:"0x4AAAAAAAECBl27OB5SZrQT",locale:{admin:"博主",sofa:"这里冷冷清清的，快来留下脚印吧！",placeholder:"根据《互联网跟帖评论服务管理规定》，将展示您的归属地，并开启强制注册登录后才允许评论\n社交登录现已支持【QQ Weibo GitHub X Facebook】等平台，登录后可点击头像更改个人主页地址，方便CC串门\n在评论框粘贴图片，自动上传至图床，请不要将评论区作为您的图床，更不要上传违法图片，谢谢合作",reactionTitle:"就现在，表明你的态度！",reaction0:"鼓励",reaction1:"菜狗",reaction2:"正确",reaction3:"错误",reaction4:"思考",reaction5:"无聊",level0:"买菜",level1:"切菜",level2:"炒菜",level3:"煲汤",level4:"煮面",level5:"上桌",level6:"开吃"},emoji:["https://jsd.cdn.zzko.cn/npm/sticker-heo/Sticker-100/"],reaction:["https://jsd.cdn.zzko.cn/npm/sticker-heo/Sticker-100/鼓掌.png","https://jsd.cdn.zzko.cn/npm/sticker-heo/Sticker-100/菜狗.png","https://jsd.cdn.zzko.cn/npm/sticker-heo/Sticker-100/正确.png","https://jsd.cdn.zzko.cn/npm/sticker-heo/Sticker-100/错误.png","https://jsd.cdn.zzko.cn/npm/sticker-heo/Sticker-100/思考.png","https://jsd.cdn.zzko.cn/npm/sticker-heo/Sticker-100/睡觉.png"]}));btf.addGlobalFn("pjax",()=>{n.destroy()},"destroyWaline")};var e=()=>{n?t(n):(btf.getCSS("https://jsd.cdn.zzko.cn/npm/@waline/client/dist/waline.css"),btf.getCSS("https://jsd.cdn.zzko.cn/npm/@waline/client/dist/waline-meta.css").then(()=>import("https://jsd.cdn.zzko.cn/npm/@waline/client/dist/waline.js")).then(({init:e})=>{n=e||Waline.init,t(n),window.walineFn=n}))};btf.loadComment(document.getElementById("waline-wrap"),e)})()</script></div><script>window.addEventListener("load",()=>{const t=e=>e=""!==e&&150<(e=(e=(e=(e=e.replace(/<img.*?src="(.*?)"?[^\>]+>/gi,"[图片]")).replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi,"[链接]")).replace(/<pre><code>.*?<\/pre>/gi,"[代码]")).replace(/<[^>]+>/g,"")).length?e.substring(0,150)+"...":e,a=t=>{let a="";if(t.length)for(let e=0;e<t.length;e++)a=(a+="<div class='aside-list-item'>")+`<div class='content'>
        <a class='comment' href='${t[e].url}' title='${t[e].content}'>${t[e].content}</a>
        <div class='name'><span>${t[e].nick} / </span><time datetime="${t[e].date}">${btf.diffDate(t[e].date,!0)}</time></div>
        </div></div>`;else a+="没有评论";var e=document.querySelector("#card-newest-comments .aside-list");e&&(e.innerHTML=a),window.lazyLoadInstance&&window.lazyLoadInstance.update(),window.pjax&&window.pjax.refresh(e)};var e=()=>{var e;document.querySelector("#card-newest-comments .aside-list")&&((e=btf.saveToLocal.get("waline-newest-comments"))?a(JSON.parse(e)):(async()=>{try{var e=(await(await fetch("https://waline.ccknbc.cc/api/comment?type=recent&count=3",{method:"GET"})).json()).data.map(e=>({content:t(e.comment),avatar:e.avatar,nick:e.nick,url:e.url+"#post-comment",date:e.time||e.insertedAt}));btf.saveToLocal.set("waline-newest-comments",JSON.stringify(e),10/1440),a(e)}catch(e){console.error(e),document.querySelector("#card-newest-comments .aside-list").textContent="无法获取评论，请确认相关配置是否正确"}})())};e(),btf.addGlobalFn("pjaxComplete",e,"waline_newestComment")})</script><script defer src="/js/custom.js"></script><script src="https://jsd.cdn.zzko.cn/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors=["head > title","#config-diff","#body-wrap","#rightside-config-hide","#rightside-config-show",".js-pjax"];var pjax=new Pjax({elements:'a:not([target="_blank"])',selectors:pjaxSelectors,cacheBust:!1,analytics:!1,scrollRestoration:!1});const triggerPjaxFn=e=>{e&&Object.values(e).forEach(e=>{e()})};document.addEventListener("pjax:send",function(){btf.removeGlobalFnEvent("pjax"),btf.removeGlobalFnEvent("themeChange");var e=document.body.classList;e.contains("read-mode")&&e.remove("read-mode"),triggerPjaxFn(window.globalFn.pjaxSend)}),document.addEventListener("pjax:complete",()=>{document.querySelectorAll("script[data-pjax]").forEach(e=>{const t=document.createElement("script");var a=e.text||e.textContent||e.innerHTML||"";Array.from(e.attributes).forEach(e=>t.setAttribute(e.name,e.value)),t.appendChild(document.createTextNode(a)),e.parentNode.replaceChild(t,e)}),triggerPjaxFn(window.globalFn.pjaxComplete)}),document.addEventListener("pjax:error",e=>{404===e.request.status&&pjax.loadUrl("/404")})</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div class="docsearch-wrap"><div id="docsearch" style="display:none"></div><link rel="stylesheet" href="https://jsd.cdn.zzko.cn/npm/@docsearch/css/dist/style.css"><script src="https://jsd.cdn.zzko.cn/npm/@docsearch/js/dist/umd/index.js"></script><script>(()=>{docsearch(Object.assign({appId:"97MUPN4DMC",apiKey:"a003a39f337f5186ec11f5f92bae62b3",indexName:"ccknbc",container:"#docsearch"},{placeholder:"Ctrl/⌘ + K 唤醒搜索服务",maxResultsPerGroup:7,translations:{button:{buttonText:"搜索",buttonAriaLabel:"搜索"},modal:{searchBox:{resetButtonTitle:"清空",resetButtonAriaLabel:"清空",cancelButtonText:"取消",cancelButtonAriaLabel:"取消"},startScreen:{recentSearchesTitle:"最近搜索历史",noRecentSearchesText:"搜索历史为空",saveRecentSearchButtonTitle:"保存搜索记录",removeRecentSearchButtonTitle:"清除搜索记录",favoriteSearchesTitle:"收藏夹",removeFavoriteSearchButtonTitle:"移出收藏夹"},errorScreen:{titleText:"未能获取搜索结果",helpText:"您可能需要检查您的网络连接"},footer:{selectText:"选择",selectKeyAriaLabel:"回车键",navigateText:"切换",navigateUpKeyAriaLabel:"方向键上",navigateDownKeyAriaLabel:"方向键下",closeText:"关闭",closeKeyAriaLabel:"退出键",searchByText:"搜索服务提供: DocSearch by"},noResultsScreen:{noResultsText:"未搜索到相关内容",suggestedQueryText:"您可尝试搜索",reportMissingResultsText:"确认搜索结果是正确的？",reportMissingResultsLinkText:"反馈给Algolia"}}}}));const e=()=>{document.querySelector(".DocSearch-Button").click()};var t=()=>{btf.addEventListenerPjax(document.querySelector("#search-button > .search"),"click",e)};t(),window.addEventListener("pjax:complete",t)})()</script></div></div><script>const copyright_enable=!0</script><script src="https://jsd.cdn.zzko.cn/npm/turndown/dist/turndown.min.js"></script><script src="https://jsd.cdn.zzko.cn/gh/ccknbc-forked/hexo-butterfly-copymarkdown/lib/copyMarkdown.min.js"></script><script src="https://jsd.cdn.zzko.cn/gh/ccknbc-forked/hexo-butterfly-copymarkdown/lib/reprint.min.js"></script><script>(function (w, d, s, id) {
        if (typeof (w.webpushr) !== 'undefined') return;
        w.webpushr = w.webpushr || function () { (w.webpushr.q = w.webpushr.q || []).push(arguments) };
        var js, fjs = d.getElementsByTagName(s)[0];
        js = d.createElement(s);
        js.id = id;
        js.async = 1;
        js.src = "https://cdn.webpushr.com/app.min.js";
        fjs.parentNode.appendChild(js);
        }(window, document, 'script', 'webpushr-jssdk'));

        webpushr('setup', {
        'key': 'BB9Y-w9p3u0CKA7UP9nupB6I-_NqE2MuODmKJjyC4W2YflX06Ff_hEhrNJfonrut5l6gCa28gC83q2OII7Qv-oA',
        'sw': 'none'
        });
        </script></body></html>